home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / parcs / parcs.lha / sample / parser-append.parcs < prev    next >
Text File  |  1992-06-08  |  956b  |  39 lines

  1. app([],X,X).
  2. app([A|X],Y,[A|Z]) :- app(X,Y,Z).
  3.  
  4. parse(Sentence,Ptree) :- s(Sentence,Ptree).
  5.  
  6. s([A|X],s(NP,VP)) :- app([B|Y],[C|Z],[A|X]),np([B|Y],NP),vp([C|Z],VP).
  7.  
  8. vp([A|X],vp(V)) :- v([A|X],V).
  9. vp([A|X],vp(V,NP)) :- app([B|Y],[C|Z],[A|X]),v([B|Y],V),np([C|Z],NP).
  10. vp([A|X],vp(VP,PP)) :- app([B|Y],[C|Z],[A|X]),vp([B|Y],VP),pp([C|Z],PP).
  11.  
  12. np([he],np(he)).
  13. np([this],np(this)).
  14. np([ken],np(ken)).
  15. np([A|X],np(N)) :- n([A|X],N).
  16. np([A|X],np(D,NP)) :- app([B|Y],[C|Z],[A|X]),d([B|Y],D),np([C|Z],NP).
  17. np([A|X],np(Adj,NP)) :- app([B|Y],[C|Z],[A|X]),a([B|Y],Adj),np([C|Z],NP).
  18. np([A|X],np(NP,PP)) :- app([B|Y],[C|Z],[A|X]),np([B|Y],NP),pp([C|Z],PP).
  19.  
  20. pp([A|X],pp(P,NP)) :- app([B|Y],[C|Z],[A|X]),p([B|Y],P),np([C|Z],NP).
  21.  
  22. n([pen],n(pen)).
  23. n([man],n(man)).
  24. n([baseball],n(baseball)).
  25. n([park],n(park)).
  26.  
  27. v([is],v(is)).
  28. v([has],v(has)).
  29. v([play],v(play)).
  30.  
  31. a([black],a(black)).
  32. a([this],a(this)).
  33.  
  34. p([with],p(with)).
  35. p([in],p(in)).
  36.  
  37. d([a],d(a)).
  38. d([the],d(the)).
  39.